package com.jrzn.view;

import android.content.Context;
import android.util.AttributeSet;

import com.handmark.pulltorefresh.library.PullToRefreshScrollView;
 /**
 * Created by haokai on 2016/6/6.
 */
public class ObserScrollview extends PullToRefreshScrollView {
     private OnScrollListener onScrollListener;

     public ObserScrollview(Context context) {
        super(context);
    }

    public ObserScrollview(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public ObserScrollview(Context context, Mode mode) {
        super(context, mode);
    }

    public ObserScrollview(Context context, Mode mode, AnimationStyle style) {
        super(context, mode, style);
    }
    /**
     * 设置滚动接口
     *
     * @param onScrollListener
     */
    public void setOnScrollListener(OnScrollListener onScrollListener) {
        this.onScrollListener = onScrollListener;
    }

    @Override
    public int computeVerticalScrollRange() {
        return super.computeVerticalScrollRange();
    }

    @Override
    protected void onScrollChanged(int l, int t, int oldl, int oldt) {
        super.onScrollChanged(l, t, oldl, oldt);
        if (onScrollListener != null) {
            onScrollListener.onScroll(t);
        }
    }

    /**
     * 滚动的回调接口
     *
     * @author
     */
    public interface OnScrollListener {
        /**
         * 回调方法， 返回MyScrollView滑动的Y方向距离
         *
         * @param scrollY 、
         */
        public void onScroll(int scrollY);
    }
}
